<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Title</title>
    <script src="../js/vue.js"></script>
</head>
    <style>
        .c{
            color: red;
        }
    </style>
<body>
    <!-- 作业需求：
    点击列表中的某一项，改项文字变成红色 -->
    <div id="app">
        <ul>
            <!-- 当前下标等于点击的下标时，设置为红色 -->
            <li v-for="(movie,index) in movies" v-on:click="changeColor(index)" :class="{c:index===currentIndex}">{{index}}、{{movie}}</li>
        </ul>
    </div>

    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                 message:'我是你爹!' ,
                 movies:['霹雳天越','霹雳靖玄录',"霹雳魔封","霹雳惊涛"],
                 c:'c',
                 isRed:false,
                 currentIndex:0,
                 
            },
            methods: {
                changeColor:function(index){
                    this.currentIndex=index;
                }
            }
        });
    </script>
</body>

</html>